package com.appapi.common;

import javax.servlet.http.HttpServletRequest;

public class FilePathUtil {  
    public static final String FILE_SEPARATOR = System.getProperty("file.separator");  
    
    public static String getRealFilePath(String path) {  
        return path.replace("/", FILE_SEPARATOR).replace("\\", FILE_SEPARATOR);  
    }  
  
    public static String getHttpURLPath(String path) {  
        return path.replace("\\", "/");  
    }
    
    public static String getRootPath() { 
    	HttpServletRequest request = ContextHolderUtils.getRequest();
    	String uploadPath = FilePathUtil.getHttpURLPath(request.getServletContext().getRealPath("/"));
		String root= FilePathUtil.getHttpURLPath(request.getContextPath());
		return uploadPath.replace(root, "");
    }
}  